package com.itheima.d7_IO.Serializable;

import java.io.*;

public class Test {
    public static void main(String[] args) throws Exception {
       //创建学生对象
        Student s = new Student("陈磊");
        // 我想把这个数据保存到磁盘里；
        OutputStream fileOutputStream = new FileOutputStream("E:\\Empty\\NewFile1.txt");
        ObjectOutputStream oos = new ObjectOutputStream(fileOutputStream);
        //2. 直接调用序列化方法
        oos.writeObject(s);
        oos.close();
    }
}

class Student implements Serializable {
    // 对象如果要序列化，必须要实现Serializable
    private String name;

    public Student() {
    }

    public Student(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                '}';
    }
}